<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ taglib uri="/WEB-INF/tlds/att.tld" prefix="att"%>
<html>

<head> 
	<meta name="decorator" content="moduleEdit"/> 
<script type="text/javascript"> 
$(document).ready(function() {
	$("#saleNo").focus();
	var actualNumber = $("#actualNumber").val();
	var actualPrice = $("#actualPrice").val();
	$("#actualAmount").focus(function(){
		
		$("#actualAmount").val($("#actualNumber").val()*$("#actualPrice").val());
	});
	$("#errorNumber").focus(function(){
		if(!$.trim($("#barCode").val()) == "" && !$.trim($("#saleNo").val()) ==""){
			$.ajax({
				type: "POST",
				url: "${contextPath}/biz/statement/statementSalesErro/ajax",
				data:{ "barCode":$.trim($("#barCode").val()),"saleNo":$.trim($("#saleNo").val())},
				success: function(json) {
					var jsonObj =eval('(' + json + ')'); 
					if(jsonObj.success){
						$("#errorNumber").val(jsonObj.data.quantity);
						$("#errorPrice").val(jsonObj.data.price);
						$("#errorAmount").val(jsonObj.data.amount);
						
					}else{
						$("#saleNo").focus();
						top.$.jBox.tip('销售单号和商品条码有误,请重新输入!','warning');
						return false;
					}
				}
			});
		}else{
			$("#saleNo").focus();
			top.$.jBox.tip('销售单号和商品条码不能为空,请重新输入!','warning');
			return false;
		}
		
	});
	$("#barCode").focus(function(){
		$("#errorNumber").val("");
		$("#errorPrice").val("");
		$("#errorAmount").val("");
		$("#messge").text("");
	});
	$("#saleNo").focus(function(){
		$("#errorNumber").val("");
		$("#errorPrice").val("");
		$("#errorAmount").val("");
		$("#messge").text("");
	});
});

</script>

</head>
<body>
	<div class="panel panel-default">
				  <div class="panel-heading">
				    <h3 class="panel-title">新增异常单信息
				    
				    <a class="btn btn-default btn-sm pull-right o-a-button" role="button" href="javascript:void(0)" onclick="history.go(-1)">返回</a>
				    <span id="messge" class=" pull-right" ></span>
				    </h3>
				    
				  </div>
				  <div class="panel-body">
					<form:form id="statementSalesErroForm" modelAttribute="statementSalesErro" action="${contextPath}/biz/statement/statementSalesErro/save" method="post"
					   class="form-horizontal" role="form" onsubmit="return check()">
						<form:hidden path="id"/>
						<form:hidden path="saleStatementId" value="${statementSalesErro.saleStatementId}"/>
						<form:hidden path="saleDate"  value="${statementSalesErro.saleDate}"/>
						<tags:message content="${message}"/>
						<div class="form-group">
							<label for="saleDate" class="col-sm-2 control-label">销售日期:</label>
							<label  for="saleDate"class="col-sm-2 control-label">
							<%--<fmt:formatDate value="${statementSalesErro.saleDate}" pattern="yyyy-MM-dd"/> --%>
								 <form:hidden path="saleDate"/>
								<input id="saleDate" name="saleDate" type="text" disabled class="form-control"
										value="<fmt:formatDate value="${statementSalesErro.saleDate}" pattern="yyyy-MM-dd"/>"/>
							</label>
							
						</div> 
						<div class="form-group">
							<div class="col-sm-6">
							    <label for="saleNo" class="col-sm-4 control-label">销售单号:</label>
							    <div class="col-sm-6">
								 <form:input path="saleNo" id="saleNo" class="form-control col-sm-2"/>
								 </div>								
						  	</div>
						  	<div class="col-sm-2">
							   <br>
						  	</div>
						  	 <div class="col-sm-6">
							    <label for="supplierNo" class="col-sm-4 control-label">供应商编码:</label>
							    <div class="col-sm-6">
								<form:input path="supplierNo" id="supplierNo" class="form-control col-sm-2" disabled="disabled" />
								</div>							
						 	</div>
						 	<div class="col-sm-6">
							    <label  class="col-sm-4 control-label">供应商名称:</label>
							    <div class="col-sm-6">
								 <form:input path="supplierName" id="supplierName" class="form-control col-sm-2" disabled="disabled" />
								 </div>
						 	</div>
						 	<div class="col-sm-2">
							   <br>
						  	</div>
						 	<div class="col-sm-6">
							    <label  class="col-sm-4 control-label">商品条码:</label>
							    <div class="col-sm-6">
								<form:input path="barCode" id="barCode" class="form-control col-sm-2" disabled="disabled" />
								</div>
						 	</div>
						 	<div class="col-sm-6">
							    <label  class="col-sm-4 control-label">有误数量:</label>
						
								<div class="col-sm-6">
									<form:input id="errorNumber" path="errorNumber" class="form-control"/>
								</div>
						  	</div>
						  	<div class="col-sm-2">
							   <br>
						  	</div>
						  	<div class="col-sm-6">
							    <label for="actualNumber" class="col-sm-4 control-label">实际数量:</label>
								<div class="col-sm-6">
									<form:input id="actualNumber" path="actualNumber" class="form-control"/>
								</div>
						  	</div>
						  	<div class="col-sm-6">
							    <label for="errorPrice" class="col-sm-4 control-label">有误单价:</label>
								<div class="col-sm-6">
									<form:input id="errorPrice" path="errorPrice" class="form-control"/>
								</div>
						  	</div>
						  	<div class="col-sm-2">
							   <br>
						  	</div>
						  	<div class="col-sm-6">
							    <label for="actualPrice" class="col-sm-4 control-label">实际单价:</label>
								<div class="col-sm-6">
									<form:input id="actualPrice" path="actualPrice" class="form-control"/>
								</div>
						  	</div>
						  	<div class="col-sm-6">
							    <label class="col-sm-4 control-label">有误金额:</label>
								<label  class="col-sm-6 control-label">
									<form:input id="errorAmount" path="errorAmount" class="form-control"/>
								</label>
						  	</div>
						  	<div class="col-sm-6">
							    <label for="actualAmount" class="col-sm-4 control-label">实际金额:</label>
								<label  class="col-sm-6 control-label">
									<form:input id="actualAmount" path="actualAmount" class="form-control"/>
								</label>
						  	</div>
						</div>
						<div class="form-group">
						  <div class="col-sm-offset-2 col-sm-10">
						    <input class="btn btn-primary" type="submit" value="提交异常"/>
							<input class="btn btn-default" type="button" value="返 回" onclick="history.go(-1)"/>
						  </div>
						</div>
					</form:form>
				  </div>
				</div>	
</body>
</html>